<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8"/>
<title>Giỏ hàng</title>
<link rel="stylesheet" href="Css/cc.css"></link>
</head>
<body>
<div class="wrapper">
<?php include 'connect.php';?>
<?php include 'menu.php';?>
<div class="content">
    <div class="regis" style="border: 1px solid #000000">
        <?php
        if (isset ($_POST['cancel'])) 
    {
        session_start();
        unset($_SESSION['cart']);
        header("location:/listcart.php");
    }
            if(isset($_POST['now']))
            {
            $id=$_POST['id'];
            $name=$_POST['name'];
            $price=$_POST['price'];
            $num=$_POST['txtsl'];
            $size=$_POST['product'];
            $image=$_POST['image'];
            if(isset($_SESSION['cart']))
            {
            $so = count($_SESSION['cart']);
            if($so = 0)
            {
                $_SESSION['cart']=array(array($id,$name,$price,$num,$size,$image));
            }
            else
            {
            array_push($_SESSION['cart'],(array($id,$name,$price,$num,$size,$image)));
            }
            }
            else
    {
        $_SESSION['cart']=array(array($id,$name,$price,$num,$size,$image));
    }
            }
        ?>
        <?php 
            if(isset($_SESSION['cart']))
            {
                $count = count($_SESSION['cart']);
                ?>
        <div><table border="0" width="100%">
                
                    <?php
                for($i=0;$i<$count;$i++)
                {
                    ?><tr>
                    <td width="20%"><img  style="width: 85px; height: 95px;" src="<?php echo $_SESSION['cart'][$i][5];?>"></img></td>
                    <td width="20%"><?php echo $_SESSION['cart'][$i][1] ?></td><td width="20%"><?php echo "Giá: ".$_SESSION['cart'][$i][2]; ?></td><td width="20%"><?php echo "Số lượng: ".$_SESSION['cart'][$i][3];?></td><td width="20%"><?php echo "Kích cỡ: ".$_SESSION['cart'][$i][4];?></td>
               </tr> <?php }?>
                </table>
        </div>
        <form method="post" action="end.php">
            <input type="submit" name="ss" class="regis_button" value="Đặt hàng"></input>
        </form>
        <form method="post" action=""><input type="submit" name="cancel" class="regis_button" value="Xóa giỏ hàng"></input></form>
            <?php }
            else{echo "Giỏ hàng rỗng!";}
        ?>
    </div>
</div>
<div class="footer">
We are... Mr.Chuot Tru, Mr.Minh Ho
<hr  width="20%" style="margin-left:40%; margin-top:8px;"/>
<pre><br /><br />
Coppyright: Aitieducation
</pre>
</div>
</div>
</div>
</body>
</html>